
var DkPromptDate =null;
function pickDate(Src , dateFormat, selectedDate)
{
	if (DkPromptDate== null || DkPromptDate.closed)
	{
		
	DkPromptDate = window.open("CalendarPopUp.aspx?src=" + Src + "&dateFormat=" + dateFormat + "&selectedDate=" + selectedDate,  
		"_blank", 
		"height=200, width=250, left=100, top=100, " +
		"location=no, menubar=no, resizable=no, " +
		"scrollbars=no, titlebar=no, toolbar=no", true);
		
	}
	else
	{
		DkPromptDate.focus();
	}
}

function dkl_getPrefixPrompt( controlName)
{
    var whereIS = controlName.indexOf("_prompt"); 
    if (whereIS!=null & whereIS>0)
    {
        var firstPart = controlName.substring(0,whereIS ); 
        return firstPart;
    }
    return null;
}

function dkl_getPrefixControl( controlName)
{
    var whereIS = controlName.indexOf("_drp"); 
    if (whereIS!=null & whereIS>0)
    {
        var firstPart = controlName.substring(0,whereIS ); 
        return firstPart;
    }
    whereIS = controlName.indexOf("_txt"); 
    if (whereIS!=null & whereIS>0)
    {
        var firstPart = controlName.substring(0,whereIS ); 
        return firstPart;
    }
    whereIS = controlName.indexOf("_dtb"); 
    if (whereIS!=null & whereIS>0)
    {
        var firstPart = controlName.substring(0,whereIS ); 
        return firstPart;
    }
    return null;
}




function dkl_getControlById(prefix, controlName)
{
	var control = document.getElementById( prefix + "_"+ controlName) ;
	//try with these combination of control names
	if (control==null)
	{
		control = document.getElementById( prefix +  controlName) ;
	}
	if (control==null)
	{
		control = document.getElementById( controlName);
	}
	return control;
}

function igdkl_getcolumnByKey(gridObject, columnKey)
{
	for (i = 0; i < gridObject.Bands.length; i++)
	{
		var band = gridObject.Bands[i];
		for (j=0; j < band.Columns.length; j++)
		{
			var column = band.Columns[j];
			if (column.Key==columnKey)
			{
				return column;
			}
		}
	}
	return null;
}

function igdkl_getcolumnValueListByGridAndKey(gridName, columnKey)
{
	var grid = igtbl_getGridById( gridName);
	if (grid!=null)
	{
		var column = igdkl_getcolumnByKey(grid, columnKey);
		if (column!=null)
		{
			return column.ValueList;
		}
	}	
	return null;
}


function igdkl_getcolumnValueListByPrefixGridAndKey(prefix, gridName, columnKey)
{
	var grid = igtbl_getGridById( gridName);
	//try with these combination of grid names
	if (grid==null)
	{
		grid = igtbl_getGridById( prefix + gridName);
	}
	if (grid==null)
	{
		grid = igtbl_getGridById( prefix + "_" + gridName);
	}
	if (grid==null)
	{
		grid = igtbl_getGridById( prefix + "x" + gridName);
	}
	if (grid!=null)
	{
		var column = igdkl_getcolumnByKey(grid, columnKey);
		if (column!=null)
		{
			return column.ValueList;
		}
	}	
	return null;
}






var g_MSXML_DOM = "MSXML2.DOMDocument.3.0";

var sGXPath = "Images/";
var xslFileName = "";
function CreateLeftPanel(xmlFile, xslFile)
{
		var oXmlTabList;
		var xmlobj = new ActiveXObject(g_MSXML_DOM);
		var xslobj = new ActiveXObject(g_MSXML_DOM);
		xslobj.async = false;
		xmlobj.async = false;
		xmlobj.load(xmlFile);
		xslobj.load(xslFile);
		var str =  xmlobj.transformNode(xslobj);
		
		document.write(str);
		
}

	function displayVirtual()
	{
		try
		{
			var currel = window.event.srcElement;
			var tagTD = currel.parentElement;
			var tagTR = tagTD.parentElement;
			var tagTABLE = tagTR.parentElement;
			var tagToHideShow = tagTABLE.all("virtual");
			if (tagToHideShow.style.display == "none")
			{
				tagToHideShow.style.display = "block";
				currel.title = "Hide";
				currel.src = sGXPath + "minus.bmp";
			}
			else
			{
				tagToHideShow.style.display="none";
				currel.title = "Show";
				currel.src = sGXPath + "plus.bmp";
			}
		}
		catch (exception)
		{
		}
	}
	function toggleView()
	{
		try
		{
		var currel = window.event.srcElement;
		var el=currel.parentElement;
		if (el.nodeName=="LI"){
			var uls=el.children;
			if (uls.length > 1){
				var ul=uls(3);
				if (ul.style.display=="none"){
					ul.style.display="block";
					currel.src = sGXPath + "arrowmin.bmp";
				}
				else {
					ul.style.display="none";
					currel.src = sGXPath + "arrowplus.bmp";
				}
			}
		}
		}
		catch (exception)
		{
		}
		window.event.cancelBubble=true;
	}

function SetXSL(xslname)
{
	xslFileName = xslname;
}

	function SetGXPath(val)
	{
		sGXPath = val +  "gxxml/";
	}


function ApplyTemplate(xmlFile,xslFile)
{
	var oXmlTabList;
	var xmlobj = new ActiveXObject(g_MSXML_DOM);
	var xslobj = new ActiveXObject(g_MSXML_DOM);
	xslobj.async = false;
	xmlobj.async = false;
	xmlobj.load(xmlFile);
	xslobj.load(xslFile);
	var str =  xmlobj.transformNode(xslobj);
	document.write(str);
}



var sFirst;


function RefreshPanel(iRow, str)
{

		var xmlobj = new ActiveXObject(g_MSXML_DOM);
		xmlobj.async = false;
		xmlobj.load(str);
		var xslobj = new ActiveXObject(g_MSXML_DOM);
		xslobj.async = false;

		xslobj.load(xslFileName);
		var sTrans = xmlobj.transformNode(xslobj);

	
		var i;
		var rowList = menu;
	
		for (i = 0 ; i < rowList.rows.length ; i++)
			rowList.rows[i].className = "clsTabItem";

		rowList.rows[iRow].className = "clsTabItemSelected";
	
		singleElement.innerHTML = sTrans;

}

function mOver(whichID)	
{
  if (whichID.className != "disabledProfile")	
    whichID.color= "white";
  
}

function mOut(whichID)	
{
  if (whichID.className != "disabledProfile")	
    whichID.color= "red";
}

	function displayNugget()
	{
	
		try
		{
		var currel = window.event.srcElement;
		oNug = currel.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
		var e = oNug.all("disp");
		var f = oNug.all("content");

		ContentRegKey = "DD_CONTENT_" + document.title + "_" + oNug.id;

		if (f.length != null)
		{
			if (f(0).style.display == "none")
			{
				e(0).title = "Hide";
				e(0).children(0).src = sGXPath + "close.gif";
				f(0).style.display = "block";
			}
			else
			{
				e(0).title = "Show";
				e(0).children(0).src = sGXPath + "open.gif";
				f(0).style.display = "none";
			}
		}
		else
		{
			//  If contents are hidden, show them
			if (f.style.display == "none")
			{
				e.title = "Hide";
				e.children(0).src = sGXPath + "close.gif";
				f.style.display = "block";
				display = "0";
				// if the page is not runin the correct security context then
				try { window.external.SetPref(ContentRegKey,"display");}
				catch (exception) {}

			}
			//  If contents are showing, hide them
			else
			{
				e.title = "Show";
				e.children(0).src = sGXPath + "open.gif";
				f.style.display = "none";
				display = "1";
				try { window.external.SetPref(ContentRegKey,"hide");}
				catch (exception) {}
			}
		 }
		}
		catch (exception)
		{
		}
	}

	function HideShowAll()
	{
		var currel = window.event.srcElement;
		var el=currel.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
		var i;
		for (i = 1; i < el.children.length ; i++)
		{
			try
			{
				HideShow(el.children(i),el.children(i).children(0).children(0).children(0).children(0).children(0).children(0));
			}
			catch (e)
			{
			}
		}
		if (currel.title == "Show All")
		{
			currel.title = "Hide All";
			currel.src = sGXPath + "minus.bmp";
		}
		else
		{
			currel.title = "Show All";
			currel.src = sGXPath + "plus.bmp";
		}
		
		
	}

	
	function HideShow(element,currel)
	{

			var el = element.children(0);
			if (el.children.length > 0)
			{
				var f = el.children(1);
				if (f.style.display != "none")
				{
					if (currel)
					{
						currel.title = "Show";
						currel.src = sGXPath + "plus.bmp";
					}
					f.style.display = "none";
				}
				else
				{
					if (currel)
					{
						currel.title = "Hide";
						currel.src = sGXPath + "minus.bmp";
					}
					f.style.display = "block";
				}
			}

		
	}
	
	function HideAndShow()
	{
			var currel = window.event.srcElement;
			var el=currel.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
			HideShow(el,currel);
	}

	function SetRowsColor(tableName)
	{
		tbl = document.all(tableName);
		for (i = 0; i < tbl.rows.length ; i++)
		{
			dr = tbl.rows(i);
			if (i % 2 == 0)
			{
				dr.className = "clsGrayFont";
			}
			else
			{
				dr.className = "text";
			}
		}
			
	}
